<?php
define( 'REAL_LENGTH', 50000 );

/**
 * This is a simple data generator, just for example
 * Instead of use data generator you can get data from a database server
 * that's real world.
 */
class LoadExample {
	
	public function load( ListRemoteViewVo $listRemoteViewVo ) {
		$data = $this->generateData( $listRemoteViewVo->index, $listRemoteViewVo->maxLength );
		
		$result = array();
		$result['data'] = $data;
		if( $listRemoteViewVo->calculateRealLength ) {
      $result['realLength'] = REAL_LENGTH;
		}

		return $result;
	}
	
	protected function generateData( $index, $length ) {
		$data = array();
		for( $i = $index; ($i < $index + $length) && ($i < REAL_LENGTH); $i++ ) {
			$item = array( 'data1' => "$i.data1", 'data2' => "$i.data2", 'data3' => "$i.data3" );
			$data[] = $item;
		}
		return $data;
	}
	
}
